import { defineComponent } from "vue";
import style from "./index.module.less";
import { CardViewProps } from "../CardView/types";
import CardView from "../CardView";
import { useRouter } from "vue-router";
export default defineComponent({
  name: "card-more",
  props: CardViewProps,
  emits: ["moreClick"],
  setup(props, { slots, emit }) {
    return () => {
      const router = useRouter();
      const onClick = () => {
        if (props.url) {
          router.push(props.url);
        } else {
          emit("moreClick");
        }
      };
      return (
        <CardView
          title={props.title}
          right={() => (
            <span class={"text-[#1989FA] text-[12px]"} onClick={onClick}>
              查看更多
            </span>
          )}
        >
          {slots.default?.()}
        </CardView>
      );
    };
  },
});
